home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 001 / xtalktip.arc / XTALK.TIP
Text File  |  1986-03-22  |  17KB  |  397 lines

  1.  
  2.               XTALK.TIP - CROSSTALK SCRIPT Writing Tips
  3.                         Version 1.0  03/22/86
  4.  
  5.                               JD Morrell
  6.                               Vienna, VA
  7.  
  8.  
  9.                               BACKGROUND
  10.  
  11. The MICROSOFT CROSSTALK script language is very powerful and a lot can
  12. be done  with it, but I do not feel that MICROSTUF has really shown us
  13. the full power of their language.  Because of this I am very surprised
  14. at the absence of magazine or newsletter articles on this topic.  What
  15. you are reading is/was the start of such an article; I just don't have
  16. the time to bring it to completion.
  17.  
  18. I have  written a  lot of  CROSSTALK scripts and I thought I would set
  19. down some  "hints and  kinks" that  I have  learned as a user over the
  20. years.   Most of  what I  have to  say is *NOT* in the manual, and has
  21. been discovered  the hard  way by  trial and error.  I assume that you
  22. have read  this manual  and  understand  the  basic  CROSSTALK  script
  23. syntax. If  you have not, don't read any further here. Come back after
  24. you have spent an hour or two with the manual.
  25.  
  26. Some of  the material  only applies  to  the  latest  version  of  the
  27. product, CROSSTALK version 3.6 dated 10/18/85. (Issue the undocumented
  28. CROSSTALK command VErsion to get this information.)
  29.  
  30. If you would like to comment, ask a specific question, or you catch an
  31. error in  this text,  I would  prefer that  you respond  to me on Gene
  32. Plantz board  in Chicago  (my ID  is ID0346)  (Gene's BBS is telephone
  33. (312) 885-9557).  I check in every 7-10 days.  Mail is okay too - 9415
  34. Delancey Dr.,  Vienna, VA 22180.  If you really can't wait, call me at
  35. (703) 938-8259.   I'll  try and give you a hand with specific scripts,
  36. but please  send me  all the  details and  don't be upset if I put you
  37. off.   I will  add to  and revise  this file  if required and there is
  38. sufficient interest.
  39.  
  40. If anyone wants to turn this into an article, go ahead.  All I want is
  41. written credit  in the  article for  the ideas and points which I have
  42. dug out the hard way and documented here,  not money.
  43.  
  44. I have  absolutely no  connection with  MICROSTUF, the  developer  and
  45. owner of  CROSSTALK,   other than  a very satisfied and heavy user for
  46. about 4  years.   MICROSTUF has neither approved (or disapproved) this
  47. text.
  48.  
  49.  
  50.                   MOST IMPORTANT: SLOW SCRIPTS DOWN!
  51.  
  52. I know  "slow-down" advice  almost sounds  un-American but the fact is
  53. that CROSSTALK scripts run *VERY* fast, a fact that can and does cause
  54. a great  deal of  difficulty for the novice.  The CROSSTALK program is
  55. written entirely  in assembler  and in  99% of  the cases  it must  be
  56. "bridled" to work with remote, host systems, especially mainframes.  I
  57. am convinced  that the  omission of delay,  i.e. CROSSTALK out-gunning
  58. the remote  computer, is  the single  most common problem with scripts
  59. written by  beginners.  In general, if your scripts don't work and you
  60. are having  difficulty "working"  with a remote computer, suspect that
  61. this is  your problem  and add delay into your script!  Within reason,
  62. you can not add too much delay or add it too often.  You will not have
  63. a failure  caused by  too much  delay, and  you can easily speed it up
  64. once things are running for you!
  65.  
  66. You can easily REply too fast (or too early) for a host; it may not be
  67. ready for  your hair-trigger response.  The symptom of this is usually
  68. garbled text echoed back from the host, like "RELL" when you know your
  69. REply command  was "MORRELL|",  or no  response at  all.   Almost as a
  70. matter of  course my scripts include a minimum of 2 tenths of a second
  71. delay (WAit  DElay 2)  prior to  any REply, especially remote prompts,
  72. and they are done like this like this, on one line:
  73.  
  74.                .
  75.                .
  76.                WAit DElay 2 : REply "MORRELL|"
  77.  
  78. Note in  particular the spaces and the quoting.  For mainframes, the 2
  79. tenths of a second delay above should be increased to 3 or 4 tenths of
  80. a second  (or more!).   If  you are dealing with a very "hot" BBS, AND
  81. you KNOW  that your  prompt trigger contains the LAST character of the
  82. prompt, you  may use  a delay  of 1  or omit  it  entirely.    (Often,
  83. however, the  last character(s)  of the  prompt (such  as  a  carriage
  84. return or,  more often,  the BELL  character) do  not  appear  on  the
  85. screen, so be careful with zero delays.)
  86.  
  87. When sending the carriage returns necessary to allow a remote computer
  88. to determine your speed (autobaud), they should generally be separated
  89. by a second or two, like this:
  90.  
  91.                 REply | : WAit DElay 17 : REply |.
  92.  
  93. If you  just send  REply ||  you will not, in most cases, achieve your
  94. objective.
  95.  
  96. If and  when you are giving REply commands to your modem (for setup of
  97. a Hayes  2400, for example) your REply commands should be separated by
  98. 10 or 20 tenths of a second.
  99.  
  100. (I assume that all have read the manual and know that CROSSTALK delays
  101. are expressed in tenths of seconds, not seconds, and the maximum delay
  102. is 254  - 25.4  seconds.) (You  may, of  course, have successive delay
  103. commands.)
  104.  
  105. I can not say it enough. ADD DELAY. ADD DELAY. ADD DELAY . . . and add
  106. it OFTEN!
  107.  
  108.  
  109.                           QUOTE REPLY FIELDS
  110.  
  111. To be safe, quote all reply fields like this:
  112.  
  113.                  REply "PASS|"     (right)
  114.                  REply PASS|       (wrong)
  115.  
  116. In some  cases you really don't need the quotes; in others you do.  It
  117. is clear  that if  your REply  contains a space, you need quotes.  But
  118. there are  other cases,  which are too difficult and time consuming to
  119. list, when  they are  required. Be on the safe side, quote all REplys,
  120. except perhaps the straight forward, simple REply |.
  121.  
  122.  
  123.                          LINE LENGTH CRITICAL
  124.  
  125. Never have  a script  line length  greater than 77 visible characters,
  126. even as part of a comment (remark) or a "MEssage" command.  Never! The
  127. result is  an immediate  abort of the script, without any warning. The
  128. manual does  *not* warn you about this.  It is usually the verbose but
  129. very simple  looking remark  line of  77/78 characters  that causes me
  130. grief!
  131.  
  132.  
  133.                          STYLE (SUGGESTIONS).
  134.  
  135. As in  all computer  languages, I  feel that "style" and general rules
  136. for the  use  of  the  language  (grammar)  are  crucially  important.
  137. Unfortunately, we  seem to be a nation of non-conformists and rebel at
  138. even the  idea of  style or  grammar.   And MICROSTUF  does not really
  139. provide us  with any guidance for use of their language.  Much of what
  140. follows then is an attempt to provide style guidelines - a style which
  141. I feel  simplifies the  process of  writing  and  debugging  CROSSTALK
  142. scripts.
  143.  
  144. Type  the  CROSSTALK  script  commands  with  the  first  two  letters
  145. capitalized, the  remainder in  lower case,  i.e.  REply "xxxx".  This
  146. reminds one that only the first two letters of a CROSSTALK command are
  147. significant, a  fact that  can come  in handy  if you must violate the
  148. line length rule above.
  149.  
  150.  
  151.                           LABELS - USE 'EM.
  152.  
  153. CROSSTALK does  not discriminate  past the 8 character in labels, i.e.
  154. PntrStep1 and  PntrStep2 are the same label, PntStep1 and PntStep2 are
  155. not the  same.   CROSSTALK treats upper and lower case as the same.  I
  156. like and recommend using the mixed-case style shown in the interest of
  157. script clarity and readability.
  158.  
  159.  
  160.                        MULTIPLE COMMAND LINES.
  161.  
  162. The CROSSTALK  manual is not clear that you may have multiple commands
  163. on a line.  You can, but be careful.  The only time you should do this
  164. when it  will clearly  enhance the readability of your scripts, and be
  165. *SURE* to precede *AND* follow the colon separator with a space!
  166.  
  167. This is  probably the  rule that  I violate  most  often,  usually  to
  168. enhance script  readability.   If I  have trouble,  however, the first
  169. thing I  suspect are  my multiple  command lines.  (The sensitivity to
  170. multiple command  lines appears  to have  become more significant with
  171. version 3.6.)
  172.  
  173.  
  174.                 AVOID WAIT STRING and WAIT CHARACTER.
  175.  
  176. I expect some screams of protest from this advice, even MICROSTUF uses
  177. "WAit STring"  in their  examples!   But use of the WAit STring "xxxx"
  178. command can  cause the  script to  hang -  stop running and wait for a
  179. string which  may never  come, possibly running up your phone bill.  I
  180. equate these  two commands  to the  "bad style" of the GOTO command of
  181. BASIC.   Avoid them.   The  better alternative  is to use the style of
  182. Example 1  which may  at first  look complex and un-necessarily formal
  183. but it really isn't.  I think it adds clarity, and eases debuging.  It
  184. also opens  the door to rudimentary logic switches, something that the
  185. present CROSSTALK  really can't do.  (Aha, but the vaporware CROSSTALK
  186. MARK IV can switch - right J.G, K.P.  and L.F.???)
  187.  
  188. Note that this style is easier to read and follow, and easier to debug
  189. too.   I recommend  it highly.   And  don't think  for a  minute  that
  190. CROSSTALK will  object to  the verboseness  that may result using this
  191. style.   I have  several 30K, 900+ line script files in daily use in a
  192. very critical government applications.  Even here, the biggest problem
  193. has been out-gunning the hosts (more of a pun than you may think!)
  194.  
  195.  
  196.             Example 1. Use of WHen in place of WAit STring
  197.                       A CROSSTALK SCRIPT segment
  198. ============================================================
  199.  
  200. LABEL WakeUp
  201. ; Purpose: Wakeup remote computer including telling him your speed.
  202. ;          then look for FIRST host prompt within time duration
  203. ;          indicated. If prompt does not appear, jump to NoGo.
  204. WHen "Name:?" JUmp MyName
  205. WAit DElay 11
  206. REply | : WAit DElay 12 : REPLY |
  207. ; (following is the "failure exit")
  208. WAit DElay 51
  209. JUmp NoGo
  210.  
  211. LABEL MyName
  212. ; Purpose: Send FIRST response while looking for SECOND host prompt.
  213. WHen "Password:?" Jump MyPass
  214. WAit DElay 2 : REply "MORRELL|"
  215. WAit DElay 52
  216. JUmp NoGo
  217.  
  218. LABEL MyPass
  219. ; Purpose: Send SECOND response while looking for THIRD host prompt.
  220. WHen "Whatever" Jump ImOn
  221. WAit DElay 2 : REply "PASS|"
  222. WAit DElay 53
  223. JUmp NoGo
  224.  
  225. LABEL ImOn
  226. ; Purpose: Set for operator interaction with host.
  227. ;          by WHen shutoff and aborting the SCRIPT (NOT THE CALL!)
  228. WHen -
  229. CLear
  230. message
  231.  
  232.  
  233.  
  234.               You are logged onto the XYZ BBS thanks to
  235.               CROSSTALK and your fine SCRIPT writing skills.
  236. .
  237. ABort
  238.  
  239. LABEL NoGo
  240. ; Purpose: Allow time for operator intervention.
  241. ;          Closes down CROSSTALK if not interrupted by operator
  242. ESCAPE.
  243. WHen -
  244. CLear
  245. ALarm 3 NOW
  246. MEssage
  247.  
  248.  
  249.  
  250.             Sorry, your autologon was not successful.
  251.             Will hang up the telephone in 10 seconds
  252.             and quit CROSSTALK.
  253. .
  254. WAit DElay 101
  255. BYe
  256. QUit
  257.  
  258. ==================== ( End of Example 1 ) ============================
  259.  
  260.  
  261. Note that  if any  string is  not received  in the specified period of
  262. time the  script "falls through" to "NoGo", which, unless the operator
  263. terminates the  script within  10 seconds (by hitting the ESC key), he
  264. will be disconnected from the telephone line and returned to DOS.
  265.  
  266. Several elements  of CROSSTALK script style are shown here.  All of my
  267. scripts use  the basic  modular, structure  shown above;  they can  be
  268. viewed as being built around WHen commands.  Each "module" has a label
  269. reflecting what  it is  to do,  followed by  a "Purpose"  comment line
  270. expanding on  what task is to be performed.  I use a delay of "51, 52,
  271. 53" to  really mean  5 seconds (rather than just 50) as clue to let me
  272. trace where I am in my script as it runs.  (A debug aid!)
  273.  
  274.  
  275.                   WHEN - THE MOST POWERFUL COMMAND.
  276.  
  277. Note that the WHen command (and many other script commands) can be set
  278. at the normal CROSSTALK command line. Typing the following:
  279.  
  280.                     WHen "MORE-Y/N" REply |
  281.  
  282. tells CROSSTALK  to send  a carriage  return when  it sees "MORE-Y/N".
  283. This can  be a  handy little  feature to  remember when  your on  line
  284. giving the same command over and over.
  285.  
  286. Be aware  that the  WHen command  can get you in LOT of trouble unless
  287. you turn  it off  explicitly with a  WHen -  command.  Once invoked it
  288. stays active even when the script is terminated (ABort'ed). This fact,
  289. by the way, can be a feature.  It can be used to restart a SCRIPT file
  290. suspended with  a WAit  MAnual command,  or to  start an  entirely new
  291. SCRIPT file!
  292.  
  293.  
  294.                             RWind - NEEDED
  295.  
  296. Use a  RWind command  before jumping  to a  label  ABOVE  the  present
  297. position in the script file. For example:
  298.  
  299.          use    WHen "MORE-Y/N"   RWind : JUmp UpAbove
  300.          but    WHen "MORE-Y/N" JUmp DnBelow
  301.                 can be used if the LABEL is below this WHen.
  302.  
  303. Be sure, if you use the WAit MAnual command and return, to use a RWind
  304. if you  JUmp to a LABEL above where you left off.  Not doing this cost
  305. me an afternoon of frustration!
  306.  
  307.  
  308.                      ELIMINATE OPERATOR PROMPTS.
  309.  
  310. If CROSSTALK  feels that  you are about to make a regrettable error it
  311. asks if you really want to do what you commanded.  For example, if the
  312. file GENE.MSG  exists on  the drive,  the script file command "CApture
  313. GENE.MSG" will  cause CROSSTALK  to ask  the operator  if he  wants to
  314. erase the  present file  first or  append to  it.  The command CApture
  315. GENE.MSG /A  causes eliminates  this warning appends to the file.  (/E
  316. would have erased the file.) This feature is part of the documentation
  317. but seems to escape the attention of many.
  318.  
  319. One one  significant place where it is *NOT* part of the documentation
  320. is an  option with  the very  useful RUn command.  I for one feel that
  321. MICROSTUF crippled  this command by requiring a user to "Press any key
  322. to return  to CROSSTALK".   But  they allow  you to  eliminate this by
  323. using the syntax:
  324.  
  325.                          RUn / MYPROG
  326.  
  327. CROSSTALK will  exit and  run the  program and  come right back to the
  328. script file  at the  point that  called it.   VERY  HANDY. I  use this
  329. feature for  a multiple  of uses  including calling a PROKEY file into
  330. the system,  issuing a form feed to the on line printer when a certain
  331. key sequence  is sent  by the  remote  computer,  switching  printers,
  332. logging time  and many  other housekeeping tasks. Let your imagination
  333. run! You can do a whole lot with this one!
  334.  
  335. A word  of caution is in order IF you call a BASIC(A) program from the
  336. RUn command.  BASIC resets the communications port resulting in a case
  337. where data  incomming data  from the  remote host  is lost.   The work
  338. around, as  reported to  me by  MICROSTUF, is  to simply  issue a POrt
  339. command immediately  upon return  to the script, like this, if you are
  340. using POrt 1:
  341.  
  342.                     RUn / BASICA MYPROG
  343.                     POrt 1
  344.  
  345. MICROSTUF  confirms   that  omission   of  the  /  modifier  from  the
  346. documentation was  unintentional, i.e  it  is  not  an  "undocumented,
  347. unsupported" feature.  (Funny, but the RUn / command was documented in
  348. the the  3.6 10/08/85  "on-line help"  section but NOT in the 10/18/85
  349. version.)
  350.  
  351.  
  352.                            LFAUTO COMMAND.
  353.  
  354. Note that  the LFauto  command does  *NOT* operate  unless INfilter is
  355. *ALSO* turned  on.  I think this is a bug. I have told MICROSTUF about
  356. it but has existed in all CROSSTALK versions from 3.2 on.
  357.  
  358.  
  359.                            3101 EMULATION.
  360.  
  361. Note that  there is  some problem  in version  3.6 10/18/85  with 3101
  362. emulation with  text overwriting  the CROSSTALK  command  line.  These
  363. errors did not occur in prior versions.
  364.  
  365.  
  366.                             SCREEN TRICKS.
  367.  
  368. Note that  you can  use the  "SCreen" commands  to change the color of
  369. your messages  on the  screen and  command line.   This  can  be  very
  370. effective in  some situations,  and as  an aid for inexperienced user.
  371. See the  manual page  52 for details.  For example, you may set colors
  372. prior to  using the  ASk command and tell the user "touch the keyboard
  373. only when the command line is green, and never when it is red."
  374.  
  375. CROSSTALK unfortunately  does not  provide any  means to  turn off the
  376. screen, i.e.   to  have host  text NOT be displayed.  Users with color
  377. systems, however,  can send  unwanted host text to the garbage heap by
  378. using a SCreen command with the following form:
  379.  
  380.                SCreen N bB
  381.  
  382. This syntax  sets the  "normal" screen  to print  a foreground of dark
  383. blue on  a background of bright blue.  All one sees is a moving cursor
  384. - no mainframe nonsense messages that might confuse a user. Just don't
  385. forget to re-set it back, something like this:
  386.  
  387.                SCreen N wb     (white on a blue background)
  388.  
  389.  
  390.                              KERMIT NOTES
  391.  
  392. I  have  found  that  KERMIT  commands  seem  to  *require*  that  the
  393. communications parameters  be set  to DAta 8. (DAta 7 does not seem to
  394. work although I think it should.)
  395.  
  396.                                                  XTALK.TIP 03/22/86
  397.